#!/usr/bin/env bash
project_path=$(cd `dirname $0`; cd ..; pwd;)
cd $project_path || exit
echoRed() {
    echo "\033[31m $1 \033[0m"
}

#更新代码
echo '----------'
echo 更新iOS代码
echo '----------'
echo ''

auto_archive=$1

# 自动打包不显示打包log
if [ ${auto_archive}x = "autox" ]; then
    projects="../MarsCarWorkspace MarsCar MarsCar_Flutter MarsCar_IM MarsCar_Kit MarsCar_Login MarsCar_Mediator MarsCar_Mine MarsCar_Stocktake"
    
    for project in $projects
    do
        cd $project_path && cd $project && pwd || exit
        
        echoRed "还原 $project 分支代码"
        git checkout .  || exit
        git clean -df  || exit
        
        echoRed "更新 $project 分支代码"
        git pull  || exit
        
        echo ""
    done
fi

echo '----------'
echo 更新iOS完毕
echo '----------'
echo ''

